home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 7: Sunsite / Linux Cubed Series 7 - Sunsite Vol 1.iso / system / shells / zsh-3.0-p / zsh-3 / zsh-3.0-pre3 / Misc / compctl-examples < prev    next >
Text File  |  1996-07-15  |  21KB  |  467 lines

  1. # $Id: compctl-examples,v 2.9 1996/07/15 04:43:21 hzoli Exp $
  2. #
  3. # This file gives examples of possible programmable completions (compctl).
  4. # You can either put the compctl commands in your .zshrc file, or put them
  5. # in a separate file (say .zcompctl) and source it from your .zshrc file.
  6. #
  7. # These are just examples. Use and modify to personal taste.  Copying
  8. # this file without thought will needlessly increase zsh's memory usage
  9. # and startup time.
  10. #
  11. # For a detailed description of how these work, check the zshcompctl man
  12. # page.
  13. #
  14. #------------------------------------------------------------------------------
  15.  
  16. # groups=( $(cut -d: -f1 /etc/group) )
  17. # groups=( $(ypcat group.byname | cut -d: -f1) ) # if you use NIS
  18.  
  19. # It can be done without forking, but it used too much memory in old zsh's:
  20. groups=( "${${(f)$(</etc/group)}%%:*}" )
  21. #groups=( "${${(f)$(ypcat groups)}%%:*}" ) # if you use NIS
  22.  
  23. # Completion for zsh builtins.
  24. compctl -z -P '%' bg
  25. compctl -j -P '%' fg jobs disown
  26. compctl -j -P '%' + -s '`ps -x | tail +2 | cut -c1-5`' wait
  27. compctl -A shift
  28. compctl -caF type whence which
  29. compctl -c unhash
  30. compctl -x 'w[1,-d] p[2]' -n - 'w[1,-d] p[3]' -g '*(-/)' - \
  31.     'p[1]' -c - 'p[2]' -g '*(-x)' -- hash
  32. compctl -F functions unfunction
  33. compctl -a unalias
  34. compctl -v getln getopts read unset vared
  35. compctl -v -S '=' -q declare export integer local readonly typeset
  36. compctl -eB -x 'p[1] s[-]' -k '(a f m r)' - \
  37.     'C[1,-*a*]' -ea - 'C[1,-*f*]' -eF - 'C[-1,-*r*]' -ew -- disable
  38. compctl -dB -x 'p[1] s[-]' -k '(a f m r)' - \
  39.     'C[1,-*a*]' -da - 'C[1,-*f*]' -dF - 'C[-1,-*r*]' -dw -- enable
  40. compctl -k "(`limit | cut -d' ' -f1`)" limit unlimit
  41. compctl -l '' -x 'p[1]' -f -- . source
  42. compctl -s '`unsetopt`' setopt
  43. # Redirection below makes zsh silent when completing unsetopt xtrace
  44. compctl -s '`setopt 2> /dev/null`' unsetopt
  45. compctl -s '${^fpath}/*(N:t)' autoload
  46. compctl -b bindkey
  47. compctl -c -x 'C[-1,-*k]' -A - 'C[-1,-*K]' -F -- compctl
  48. compctl -x 'C[-1,-*e]' -c - 'C[-1,-[ARWI]##]' -f -- fc
  49. compctl -x 'p[1]' - 'p[2,-1]' -l '' -- sched
  50. compctl -x 'C[-1,[+-]o]' -o - 'c[-1,-A]' -A -- set
  51.  
  52. # Anything after nohup is a command by itself with its own completion
  53. compctl -l '' nohup noglob exec nice eval - time rusage
  54. compctl -l '' -x 'p[1]' -eB -- builtin
  55. compctl -l '' -x 'p[1]' -em -- command
  56. compctl -x 'p[1]' -c - 'p[2,-1]' -k signals -- trap
  57. #------------------------------------------------------------------------------
  58. # kill takes signal names as the first argument after -, but job names after %
  59. # or PIDs as a last resort
  60. compctl -j -P '%' + -s '`ps -x | tail +2 | cut -c1-5`' + \
  61.     -x 's[-] p[1]' -k "($signals[1,-3])" -- kill
  62. #------------------------------------------------------------------------------
  63. compctl -s '$(groups)' + -k groups newgrp
  64. compctl -f -x 'p[1], p[2] C[-1,-*]' -k groups -- chgrp
  65. compctl -f -x 'p[1] n[-1,.], p[2] C[-1,-*] n[-1,.]' -k groups \
  66.     - 'p[1], p[2] C[-1,-*]' -u -S '.' -- chown
  67. compctl -g '*.x' + -g '*(-/)' rpcgen
  68. compctl -u -x 's[+] c[-1,-f],s[-f+]' -g '~/Mail/*(:t)' - \
  69.     's[-f],c[-1,-f]' -f -- mail elm
  70. #------------------------------------------------------------------------------
  71. compctl -s "\$(awk '/^[a-zA-Z0-9][^     ]+:/ {print \$1}' FS=: [mM]akefile)" -x \
  72.     'c[-1,-f]' -f -- make gmake
  73. compctl -f -x 'C[-1,*f*] p[2]' -g "*.tar" -- tar
  74. #------------------------------------------------------------------------------
  75. # rmdir only real directories
  76. compctl -g '*(/)' rmdir dircmp
  77. #------------------------------------------------------------------------------
  78. # cd/pushd only directories or symbolic links to directories
  79. compctl -g '*(-/)' cd pushd
  80.  
  81. # Another possibility for cd/pushd is to use it in conjunction with the
  82. # cdmatch function (in the Functions subdirectory of zsh distribution).
  83. if [[ -o AUTO_REMOVE_SLASH ]] then
  84.     compctl -x 'p[2]' -Q -K cdmatch2 - 'S[/][~][./][../]' -g '*(-/)' + \
  85.     -g '*(-/D)' - 'n[-1,/], s[]' -K cdmatch -q -S '/' -- cd pushd
  86. else
  87.     compctl -x 'p[2]' -Q -K cdmatch2 - 'S[/][~][./][../]' -g '*(-/)' + \
  88.     -g '*(-/D)' - 'n[-1,/], s[]' -K cdmatch -S '/' -- cd pushd
  89. fi
  90. #------------------------------------------------------------------------------
  91. # If the command is rsh, make the first argument complete to hosts and treat the
  92. # rest of the line as a command on its own.
  93. compctl -k hosts -x 'p[2,-1]' -l '' -- rsh
  94.  
  95. # rlogin takes hosts and users after `-l'
  96. compctl -k hosts -x 'c[-1,-l]' -u -- rlogin
  97.  
  98. # rcp: match files *and* hosts initially, match files after a :, if the first
  99. # argument contained a : then the second matches files and vice versa.
  100. compctl -f -k hosts -x 'n[1,:]' -f - \
  101.     'p[1] W[2,*:*]' -f - 'p[1]' -k hosts -S ':' - \
  102.     'p[2] W[1,*:*]' -f - 'p[2]' -k hosts -S ':' -- rcp
  103. #------------------------------------------------------------------------------
  104. # strip, profile, and debug only executables.  The compctls for the
  105. # debuggers could be better, of course.
  106. compctl -g '*(*)' strip gprof adb dbx xdbx ups
  107. #------------------------------------------------------------------------------
  108. # su takes an username and args for the shell.  The `-c' case is
  109. # handled specially here.
  110. compctl -u -x 'w[2,-c] p[3,-1]' -l '' -- su
  111. #------------------------------------------------------------------------------
  112. # Run ghostscript on postscript files, but if no postscript file matches what
  113. # we already typed, complete directories as the postscript file may not be in
  114. # the current directory.
  115. compctl -g '*.(e|)ps' + -g '*(-/)' gs ghostview psps pstops psmulti psselect
  116. #------------------------------------------------------------------------------
  117. # Similar things for tex, texinfo and dvi files.
  118. compctl -g '*.tex*' + -g '*(-/)' {,la,gla,ams{la,},{g,}sli}tex texi2dvi
  119. compctl -g '*.dvi' + -g '*(-/)' xdvi dvips
  120. #------------------------------------------------------------------------------
  121. # For rcs users, co and rlog from the RCS directory.  We don't want to see
  122. # the RCS and ,v though.
  123. compctl -g 'RCS/*(:s@RCS/@@:s/,v//)' co rlog rcs rcsdiff
  124. #------------------------------------------------------------------------------
  125. # gzip uncompressed files, but gzip -d only gzipped or compressed files
  126. compctl -x 'R[-*[dt],^*]' -g '*.(gz|z|Z|t[agp]z|tarZ|tz)' + -g '*(-/)' + -f - \
  127.     's[]' -g '^*(.(tz|gz|t[agp]z|tarZ|zip|ZIP|jpg|JPG|gif|GIF|[zZ])|[~#])' \
  128.     + -f -- gzip
  129. compctl -g '*.(gz|z|Z|t[agp]z|tarZ|tz)' + -g '*(-/)' gunzip # zcat if you use GNU
  130. compctl -g '*.Z' + -g '*(-/)' uncompress zmore  # zcat if you don't use GNU
  131. compctl -g '*.F' + -g '*(-/)' melt fcat
  132. #------------------------------------------------------------------------------
  133. # ftp takes hostnames
  134. ftphosts=(prep.ai.mit.edu wuarchive.wustl.edu ftp.uu.net ftp.math.gatech.edu)
  135. compctl -k ftphosts ftp
  136.  
  137. # Some systems have directories containing indices of ftp servers.
  138. # For example: we have the directory /home/ftp/index/INDEX containing
  139. # files of the form `<name>-INDEX.Z', this leads to:
  140. compctl -g '/home/ftp/index/INDEX/*-INDEX.Z(:t:r:s/-INDEX//)' ftp tftp
  141. #------------------------------------------------------------------------------
  142. # Change default completion (see the multicomp function in the Function
  143. # subdirectory of the zsh distribution).
  144. compctl -D -f + -U -K multicomp
  145. # If completion of usernames is slow for you, you may want to add something
  146. # like
  147. #    -x 'C[0,*/*]' -f - 's[~]' -S/ -k users + -u
  148. # where `users' contains the names of the users you want to complete often.
  149. # If you want to use this and to be able to complete named directories after
  150. # the `~' you should add `+ -n' at the end
  151. #------------------------------------------------------------------------------
  152. # This is to complete all directories under /home, even those that are not
  153. # yet mounted (if you use the automounter).
  154.  
  155. # This is for NIS+ (e.g. Solaris 2.x)
  156. compctl -Tx 's[/home/] C[0,^/home/*/*]'  -S '/' -s '$(niscat auto_home.org_dir | \
  157.     awk '\''/export\/[a-zA-Z]*$/ {print $NF}'\'' FS=/)'
  158.  
  159. # And this is for YP (e.g. SunOS4.x)
  160. compctl -Tx 's[/home/] C[0,^/home/*/*]' -S '/' -s '$(ypcat auto.home | \
  161.     awk '\''/export\/[a-zA-Z]*$/ {print $NF}'\'' FS=/)'
  162. #------------------------------------------------------------------------------
  163. # Find is very system dependent, this one is for GNU find.
  164. # Note that 'r[-exec,;]' must come first
  165. # On Linux use 'c[-1,-fstype]' -s '$(cut -f2 /proc/filesystems)' 
  166. compctl -x 'r[-exec,;][-ok,;]' -l '' - \
  167. 's[-]' -s 'daystart {max,min,}depth follow noleaf version xdev \
  168.     {a,c,}newer {a,c,m}{min,time} empty false {fs,x,}type gid inum links \
  169.     {i,}{l,}name {no,}{user,group} path perm regex size true uid used \
  170.     exec {f,}print{f,0,} ok prune ls' - \
  171. 'p[1]' -g '. .. *(-/)' - \
  172. 'C[-1,-((a|c|)newer|fprint(|0|f))]' -f - \
  173. 'c[-1,-fstype]' -k '(ufs 4.2 4.3 nfs tmp mfs S51K S52K)' - \
  174. 'c[-1,-group]' -k groups - \
  175. 'c[-1,-user]' -u -- find
  176. #------------------------------------------------------------------------------
  177. # Generic completion for C compiler.
  178. compctl -g "*.[cCoa]" -x 's[-I]' -g "*(/)" - \
  179.     's[-l]' -s '${(s.:.)^LD_LIBRARY_PATH}/lib*.a(:t:r:s/lib//)' -- cc
  180. #------------------------------------------------------------------------------
  181. # GCC completion, by Andrew Main
  182. # completes to filenames (*.c, *.C, *.o, etc.); to miscellaneous options after
  183. # a -; to various -f options after -f (and similarly -W, -g and -m); and to a
  184. # couple of other things at different points.
  185. # The -l completion is nicked from the cc compctl above.
  186. # The -m completion should be tailored to each system; the one below is i386.
  187. compctl -g '*.([cCmisSoa]|cc|cxx|ii)' -x \
  188.     's[-l]' -s '${(s.:.)^LD_LIBRARY_PATH}/lib*.a(:t:r:s/lib//)' - \
  189.     'c[-1,-x]' -k '(none c objective-c c-header c++ cpp-output assembler assembler-with-cpp)' - \
  190.     'c[-1,-o]' -f - \
  191.     'C[-1,-i(nclude|macros)]' -g '*.h' - \
  192.     'C[-1,-i(dirafter|prefix)]' -g '*(-/)' - \
  193.     's[-B][-I][-L]' -g '*(-/)' - \
  194.     's[-fno-],s[-f]' -k '(all-virtual cond-mismatch dollars-in-identifiers enum-int-equiv external-templates asm builtin strict-prototype signed-bitfields signd-char this-is-variable unsigned-bitfields unsigned-char writable-strings syntax-only pretend-float caller-saves cse-follow-jumps cse-skip-blocks delayed-branch elide-constructors expensive-optimizations fast-math float-store force-addr force-mem inline-functions keep-inline-functions memoize-lookups default-inline defer-pop function-cse inline peephole omit-frame-pointer rerun-cse-after-loop schedule-insns schedule-insns2 strength-reduce thread-jumps unroll-all-loops unroll-loops)' - \
  195.     's[-g]' -k '(coff xcoff xcoff+ dwarf dwarf+ stabs stabs+ gdb)' - \
  196.     's[-mno-][-mno][-m]' -k '(486 soft-float fp-ret-in-387)' - \
  197.     's[-Wno-][-W]' -k '(all aggregate-return cast-align cast-qual char-subscript comment conversion enum-clash error format id-clash-6 implicit inline missing-prototypes missing-declarations nested-externs import parentheses pointer-arith redundant-decls return-type shadow strict-prototypes switch template-debugging traditional trigraphs uninitialized unused write-strings)' - \
  198.     's[-]' -k '(pipe ansi traditional traditional-cpp trigraphs pedantic pedantic-errors nostartfiles nostdlib static shared symbolic include imacros idirafter iprefix iwithprefix nostdinc nostdinc++ undef)' -X 'Use "-f", "-g", "-m" or "-W" for more options' -- gcc g++
  199. #------------------------------------------------------------------------------
  200. # There are (at least) two ways to complete manual pages.  This one is
  201. # extremely memory expensive if you have lots of man pages
  202. man_var() {
  203.    man_pages=( ${^manpath}/man*/*(N:t:r) )
  204.    compctl -k man_pages man
  205.    reply=( $man_pages )
  206. }
  207. compctl -K man_var man
  208.  
  209. # This one isn't that expensive but somewhat slower
  210. man_glob () {
  211.    local a
  212.    read -cA a
  213.    if [[ $a[2] = -s ]] then         # Or [[ $a[2] = [0-9]* ]] for BSD
  214.      reply=( ${^manpath}/man$a[3]/$1*$2(N:t:r) )
  215.    else
  216.      reply=( ${^manpath}/man*/$1*$2(N:t:r) )
  217.    fi
  218. }
  219. compctl -K man_glob man
  220. #------------------------------------------------------------------------------
  221. # xsetroot: gets possible colours, cursors and bitmaps from wherever.
  222. # Uses two auxiliary functions.  You might need to change the path names.
  223. # The =:- can be omitted if you use a beta6-hzoli4 or later version.
  224. Xcolours() {
  225.   reply=( ${(L)=:-$(awk '{ if (NF = 4) print $4 }' < /usr/openwin/lib/X11/rgb.txt)} )
  226. }
  227. Xcursor() {
  228.   reply=( $(sed -n 's/^#define[     ][     ]*XC_\([^     ]*\)[     ].*$/\1/p' \
  229.       < /usr/include/X11/cursorfont.h) )
  230. }
  231. compctl -k '(-help -def -display -cursor -cursor_name -bitmap -mod -fg -bg
  232.    -grey -rv -solid -name)' -x 'c[-1,-display]' -k hosts -S ':0.0' - \
  233.    'c[-1,-cursor]' -f -  'c[-2,-cursor]' -f - \
  234.    'c[-1,-bitmap]' -g '/usr/include/X11/bitmaps/*' - \
  235.    'c[-1,-cursor_name]' -K Xcursor - \
  236.    'C[-1,-(solid|fg|bg)]' -K Xcolours -- xsetroot
  237. #------------------------------------------------------------------------------
  238. # dd
  239. compctl -k '(if of conv ibs obs bs cbs files skip file seek count)' \
  240.     -S '=' -x 's[if=], s[of=]' -f - 'C[0,conv=*,*] n[-1,,], s[conv=]' \
  241.     -k '(ascii ebcdic ibm block unblock lcase ucase swap noerror sync)' \
  242.     -q -S ',' - 'n[-1,=]' -X '<number>'  -- dd
  243. #------------------------------------------------------------------------------
  244. # Various MH completions by Peter Stephenson
  245. # You may need to edit where it says *Edit Me*.
  246.  
  247. # The following three functions are best autoloaded.
  248. # mhcomp completes folders (including subfolders),
  249. # mhfseq completes sequence names and message numbers,
  250. # mhfile completes files in standard MH locations.
  251.  
  252. function mhcomp {
  253.   # Completion function for MH folders.
  254.   # Works with both + (rel. to top) and @ (rel. to current).
  255.   local nword args pref char mhpath
  256.   read -nc nword
  257.   read -cA args
  258.  
  259.   pref=$args[$nword]
  260.   char=$pref[1]
  261.   pref=$pref[2,-1]
  262.  
  263.   # The $(...) here accounts for most of the time spent in this function.
  264.   if [[ $char = + ]]; then
  265.   #    mhpath=$(mhpath +)
  266.   # *Edit Me*: use a hard wired value here: it's faster.
  267.     mhpath=~/Mail
  268.   elif [[ $char = @ ]]; then
  269.     mhpath=$(mhpath)
  270.   fi
  271.  
  272.   eval "reply=($mhpath/$pref*(N-/))"
  273.  
  274.   # I'm frankly amazed that this next step works, but it does.
  275.   reply=(${reply#$mhpath/})
  276. }
  277.  
  278. mhfseq() {
  279.   # Extract MH message names and numbers for completion.  Use of the
  280.   # correct folder, if it is not the current one, requires that it
  281.   # should be the previous command line argument.  If the previous
  282.   # argument is `-draftmessage', a hard wired draft folder name is used.
  283.  
  284.   local folder foldpath words pos nums
  285.   read -cA words
  286.   read -cn pos
  287.  
  288.   # Look for a folder name.
  289.   # First try the previous word.
  290.   if [[ $words[$pos-1] = [@+]* ]]; then
  291.     folder=$words[$pos-1]
  292.   # Next look and see if we're looking for a draftmessage
  293.   elif [[ $words[$pos-1] = -draftmessage ]]; then
  294.     # *Edit Me*:  shortcut -- hard-wire draftfolder here
  295.     # Should really look for a +draftfolder argument.
  296.     folder=+drafts
  297.   fi
  298.   # Else use the current folder ($folder empty)
  299.  
  300.   if [[ $folder = +* ]]; then
  301.   # *Edit Me*:  use hard-wired path with + for speed.
  302.     foldpath=~/Mail/$folder[2,-1]
  303.   else
  304.     foldpath=$(mhpath $folder)
  305.   fi
  306.  
  307.   # Extract all existing message numbers from the folder.
  308.   nums=($foldpath/<->(N:t))
  309.   # If that worked, look for marked sequences.
  310.   # *Edit Me*: if you never use non-standard sequences, comment out
  311.   # or delete the next three lines.
  312.   if (( $#nums )); then
  313.     nums=($nums $(mark $folder | awk -F: '{print $1}'))
  314.   fi
  315.  
  316.   # *Edit Me*:  `unseen' is the value of Unseen-Sequence, if it exists;
  317.   set -A reply next cur prev first last all unseen $nums
  318.  
  319. }
  320.  
  321. mhfile () {
  322.   # Find an MH file; for use with -form arguments and the like.
  323.   # Use with compctl -K mhfile.
  324.  
  325.   local mhfpath file
  326.   # *Edit Me*:  Array containing all the places MH will look for templates etc.
  327.   mhfpath=(~/Mail /usr/local/lib/MH)
  328.  
  329.   # Emulate completeinword behaviour as appropriate
  330.   local wordstr
  331.   if [[ -o completeinword ]]; then
  332.     wordstr='$1*$2'
  333.   else
  334.     wordstr='$1$2*'
  335.   fi
  336.  
  337.   if [[ $1$2 = */* ]]; then
  338.     # path given: don't search MH locations
  339.     eval "reply=($wordstr(.N))"
  340.   else
  341.     # no path:  only search MH locations.
  342.     eval "reply=(\$mhfpath/$wordstr(.N:t))"
  343.   fi
  344. }
  345.  
  346. # Note: you must type the initial + or @ of a folder name to get
  347. # completion, even in places where only folder names are allowed.
  348. # Abbreviations for options are not recognised.  Hit tab to complete
  349. # the option name first.
  350. compctl -K mhfseq -x 's[+][@]' -K mhcomp -S / -q - \
  351.   's[-]' -k "(all fast nofast header noheader help list nolist \
  352.   pack nopack pop push recurse norecurse total nototal)" -- folder
  353. compctl -K mhfseq -x 's[+][@],c[-1,-draftfolder] s[+][@]' \
  354.   -K mhcomp -S / -q - 'c[-1,-draftmessage]' -K mhfseq - \
  355.   'C[-1,-(editor|whatnowproc)]' -c - \
  356.   's[-]' -k "(draftfolder draftmessage nodraftfolder editor noedit \
  357.   file form use nouse whatnowproc nowhatnowproc help)" - \
  358.   'c[-1,-form]' -K mhfile -- comp
  359. compctl -K mhfseq -x 's[+][@]' -K mhcomp -S / -q - \
  360.   's[-]' -k "(audit noaudit changecur nochangecur form format \
  361.   file silent nosilent truncate notruncate width help)" - \
  362.   'C[-1,-(audit|form)]' -K mhfile - 'c[-1,file]' -f + -- inc
  363. compctl -K mhfseq -x 's[+][@]' -K mhcomp -S / -q - \
  364.   's[-]' -k "(sequence add delete list public nopublic zero nozero help)" -- \
  365.   mark
  366. compctl -K mhfseq -x 's[+][@]' \
  367.   -K mhcomp -S / -q - 'c[-1,-file]' -f - 'c[-1,-rmmprov]' -c - \
  368.   's[-]' -k "(draft link nolink preserve nopreserve src file \
  369.   rmmproc normmproc help)" -- refile
  370. compctl -K mhfseq -x 's[+][@]' \
  371.   -K mhcomp -S / -q - 'c[-1,-draftmessage]'  -K mhfseq -\
  372.   's[-]' -k "(annotate noannotate cc nocc draftfolder nodraftfolder \
  373.   draftmessage editor noedit fcc filter form inplace noinplace query \
  374.   noquery width whatnowproc nowhatnowproc help)" - 'c[-1,(cc|nocc)]' \
  375.   -k "(all to cc me)" - 'C[-1,-(filter|form)]' -K mhfile - \
  376.   'C[-1,-(editor|whatnowproc)]' -c -- repl
  377. compctl -K mhfseq -x 's[+][@]' -K mhcomp -S / -q - \
  378.   's[-]' -k "(clear noclear form format header noheader reverse noreverse \
  379.   file help width)" - 'c[-1,-file]' -f - 'c[-1,-form]' -K mhfile -- scan
  380. compctl -K mhfseq -x 's[+][@]'  -K mhcomp -S / -q - \
  381.   's[-]' -k "(draft header noheader showproc noshowproc)" - \
  382.   'c[-1,showproc]' -c -- show next prev
  383. compctl -K mhfseq -x 's[+][@]' -K mhcomp -S / -q - 's[-]' \
  384.   -k "(help)" -- rmm
  385. compctl -K mhfseq -x 's[+][@]' -K mhcomp -S / -q - \
  386.   's[-]' -k "(after before cc date datefield from help list nolist \
  387.   public nopublic search sequence subject to zero nozero not or and \
  388.   lbrace rbrace)" -- pick
  389. compctl -K mhfseq -x 's[+][@]' -K mhcomp -S / -q - 's[-]' \
  390.   -k "(alias check draft draftfolder draftmessage help nocheck \
  391.   nodraftfolder)" -- whom
  392. #------------------------------------------------------------------------------
  393. # By Bart Schaefer
  394. # CVS -- there's almost no way to make this all-inclusive, but ...
  395. #
  396. cvsflags=(-H -Q -q -r -w -l -n -t -v -b -e -d)
  397. cvscmds=(add admin checkout commit diff history import export log rdiff
  398.         release remove status tag rtag update)
  399.  
  400. # diff assumes gnu rcs using gnu diff
  401. # log assumes gnu rcs
  402.  
  403. compctl -k "($cvscmds $cvsflags)" \
  404.     -x "c[-1,-D]" -k '(today yesterday 1\ week\ ago)' \
  405.     - "r[add,;]" -k "(-k -m)" -f \
  406.     - "r[admin,;]" -K cvstargets \
  407.     - "r[checkout,;]" -k "(-A -N -P -Q -c -f -l -n -p -q -s -r -D -d -k -j)" \
  408.     - "r[commit,;]" -k "(-n -R -l -f -m -r)"  -K cvstargets \
  409.     - "r[diff,;]" -k "(-l -D -r -c -u -b -w)" -K cvstargets \
  410.     - "r[history,;]" \
  411.     -k "(-T -c -o -m -x -a -e -l -w -D -b -f -n -p -r -t -u)" \
  412.     -K cvstargets \
  413.     - "r[history,;] c[-1,-u]" -u \
  414.     - "r[import,;]" -k "(-Q -q -I -b -m)" -f \
  415.     - "r[export,;]" -k "(-N -Q -f -l -n -q -r -D -d)" -f \
  416.     - "R[(r|)log,;]" -k "(-l -R -h -b -t -r -w)" -K cvstargets \
  417.     - 'R[(r|)log,;] s[-w] n[-1,,],s[-w]' -u -S , -q \
  418.     - "r[rdiff,;]" -k "(-Q -f -l -c -u -s -t -D -r -V)" -K cvstargets \
  419.     - "r[release,;]" -k "(-Q -d -q)" -f \
  420.     - "r[remove,;]" -k "(-l -R)" -K cvstargets \
  421.     - "r[status,;]" -k "(-v -l -R)" -K cvstargets \
  422.     - "r[tag,;]" -k "(-Q -l -R -q -d -b)" -K cvstargets \
  423.     - "r[rtag,;]" -k "(-Q -a -f -l -R -n -q -d -b -r -D)" -f \
  424.     - "r[update,;]" -k "(-A -P -Q -d -f -l -R -p -q -k -r -D -j -I)" \
  425.     -K cvstargets \
  426.     -- cvs
  427. unset cvsflags cvscmds
  428.  
  429. cvstargets() {
  430.     local nword args pref f
  431.     setopt localoptions nullglob
  432.     read -nc nword; read -Ac args
  433.     pref=$args[$nword]
  434.     if [[ -d $pref:h && ! -d $pref ]]
  435.     then
  436.     pref=$pref:h
  437.     elif [[ $pref != */* ]]
  438.     then
  439.     pref=
  440.     fi
  441.     [[ -n "$pref" && "$pref" != */ ]] && pref=$pref/
  442.     if [[ -f "${pref}CVS/Entries" ]] then
  443.     reply=( "${pref}${^${${(f@)$(cat ${pref}CVS/Entries 2> /dev/null)}#/}%%/*}"
  444.         ${pref}*/**/CVS(:h) )
  445.     else
  446.     reply=( ${pref}*/**/CVS(:h) )
  447.     fi
  448. }
  449. #------------------------------------------------------------------------------
  450. # RedHat Linux rpm utility
  451. #
  452. compctl -s '$(rpm -qa)' \
  453.     -x 's[--]' -s 'oldpackage percent replacefiles replacepkgs noscripts
  454.                root excludedocs includedocs test upgrade test clean
  455.                short-circuit sign recompile rebuild resign querytags
  456.                queryformat version help quiet rcfile force hash' - \
  457.     's[ftp:]' -P '//' -s '$(</u/zsh/ftphosts)' -S '/' - \
  458.     'c[-1,--root]' -g '*(-/)' - \
  459.     'c[-1,--rcfile]' -f - \
  460.     'p[1] s[-b]' -k '(p l c i b a)' - \
  461.     'c[-1,--queryformat] N[-1,{]' \
  462.         -s '"${${(f)$(rpm --querytags)}#RPMTAG_}"' -S '}' - \
  463.     'W[1,-q*] C[-1,-([^-]*|)f*]' -f - \
  464.     'W[1,-i*], W[1,-q*] C[-1,-([^-]*|)p*]' \
  465.         -g '*.rpm' + -g '*(-/)' + -f -- rpm
  466. #------------------------------------------------------------------------------
  467.